package com.suitsoft.ut.dao.commons;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;


/**
 * 公共Dao
 * @author Genius
 *
 */
@Repository
public class CommonsDao {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	/** 数据库访问模板. */
	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	/**
	 * 获取分页行数.
	 * @param pmky
	 * @return
	 */
	public Map<String, Object> getPageSize(String pmky) {
		Map<String, Object> result = null;

		StringBuffer buffer = new StringBuffer();
		buffer.append("SELECT SYSTEM_KEY_CODE,MEMO FROM HR_SYSTEM_INFO");
		buffer.append(" WHERE CATEGORY_KEY_CODE ");
		buffer.append("		= (SELECT CATEGORY_KEY_CODE FROM ");
		buffer.append("HR_SYSTEM_CATEGORY WHERE PMKY = '" + pmky + "')");

		String query = buffer.toString();


		try {
			result = jdbcTemplate.queryForMap(query);
		} catch (EmptyResultDataAccessException e) {
			logger.error("未找到每页行数配置项...");
		}

		return result;
	}
}
